Skip to content

Conversation

@terrerox
Copy link
Contributor

@terrerox terrerox commented Feb 11, 2026

Description

For more context please see this comment.

  • Extend retry mechanism to handle server errors (5xx), CORS errors, and network failures with
    exponential backoff
  • Add RetryReason enum to distinguish between rate limit and server error retries
  • Update onRetry callbacks to include retry reason parameter
  • Add HTTP status codes for server errors (500, 502, 503, 504) to constants
  • Add CORS to ErrorMessages enum
  • Rename retry-with-rate-limit to retry-with-backoff to reflect broader functionality
  • Improve test coverage and descriptions

Related Issues

Related Pull Requests

Checklist

  • Changes have been tested locally.
  • Unit tests have been written or updated as necessary.
  • The code adheres to the repository's coding standards.
  • Relevant documentation has been added or updated.
  • No new warnings or errors have been introduced.
  • SonarCloud issues have been reviewed and addressed.
  • QA Passed

Testing Process

Additional Notes

@terrerox terrerox requested review from a team, CandelR and larryrider as code owners February 11, 2026 05:16
@terrerox terrerox self-assigned this Feb 11, 2026
@terrerox terrerox marked this pull request as draft February 11, 2026 05:16
@terrerox terrerox changed the title refactor: enhance retry logic with server error handling and retry reason differentiation [BR-1794]: Enhance retry logic with server error handling and retry reason differentiation Feb 11, 2026
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 11, 2026

Deploying drive-web with  Cloudflare Pages  Cloudflare Pages

Latest commit: 83dcf5f
Status: ✅  Deploy successful!
Preview URL: https://1ae87a65.drive-web.pages.dev
Branch Preview URL: https://feature-retry-with-backoff-s.drive-web.pages.dev

View logs

  - Extend retry mechanism to handle server errors (5xx), CORS errors, and network failures with
  exponential backoff
  - Add RetryReason enum to distinguish between rate limit and server error retries
  - Update onRetry callbacks to include retry reason parameter
  - Add HTTP status codes for server errors (500, 502, 503, 504) to constants
  - Add CORS to ErrorMessages enum
  - Rename retry-with-rate-limit to retry-with-backoff to reflect broader functionality
  - Improve test coverage and descriptions
@terrerox terrerox force-pushed the feature/retry-with-backoff-server-errors branch from c65f899 to 31b200e Compare February 12, 2026 02:00
@terrerox terrerox changed the title [BR-1794]: Enhance retry logic with server error handling and retry reason differentiation [BR-1794]: Add server error retry with exponential backoff Feb 12, 2026
@sonarqubecloud
Copy link

@terrerox terrerox marked this pull request as ready for review February 12, 2026 02:19
it('when server error persists then throws after max retries', async () => {
const mockFn = vi.fn().mockRejectedValue({ status: 500, message: 'Server Error' });

await expect(retryWithBackoff(mockFn, { maxRetries: 2 })).rejects.toEqual({ status: 500, message: 'Server Error' });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't maxRetries=5 by default?

@TamaraFinogina
Copy link
Contributor

LGTM. Math is what everyone else uses for computing time variation, even if Sonar complains.

Btw, @CandelR @larry-internxt Maybe it's easier and cleaner if we use a third-party library for retries?
Something like https://github.com/softonic/axios-retry or https://github.com/sindresorhus/p-retry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants